package com.example.learn_spring_boot3.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseData <T extends Object>{
    /**
     * 响应状态吗
     */
    public int code;

    /**
     * 响应提示语
     */
    public String msg;

    /**
     * 响应数据
     */
    public T data;

    /**
     * 成功响应数据
     */
    public static final ResponseData<Object> success(Object d) {
        return new ResponseData(200, "操作成功", d);
    }

    /**
     * 失败响应数据
     */
    public static final ResponseData<Object> error(int c, String m, Object d) {
        return new ResponseData(c, m, d);
    }
}
